<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
	xmlns:h="http://java.sun.com/jsf/html"
	xmlns:f="http://java.sun.com/jsf/core"
	xmlns:ui="http://java.sun.com/jsf/facelets">

<!-- 
		Replace path to template, title, header and body
		with actual data.
	 -->
<ui:composition template="/templates/template.xhtml">
	<ui:define name="pageTitle">Construtora</ui:define>
	<ui:define name="pageHeader">Cadastro de Construtoras</ui:define>
	<ui:define name="body">
		<h:form id="edicao">
			<h:messages />

			<h:inputHidden value="#{construtoraBean.construtoraSelecionada.id}" />

			<h:panelGrid columns="2">
				<h:outputLabel value="Razão Social:" />
				<h:inputText id="Razao_Social"
					value="#{construtoraBean.construtoraSelecionada.razaoSocial}" required="true" requiredMessage="Razão Social: Campo obrigatório." />

				<h:outputLabel value="CNPJ:" />
				<h:inputText id="CNPJ" value="#{construtoraBean.construtoraSelecionada.cnpj}" required="true" requiredMessage="CNPJ: Campo obrigatório." />

				<h:outputLabel value="Logotipo::" />
				<h:inputText value="#{construtoraBean.construtoraSelecionada.logo}" />
			</h:panelGrid>
			<h:commandButton value="Salvar" action="#{construtoraBean.salvar()}" />
			<h:commandButton value="Nova Construtora" action="#{construtoraBean.novo()}" />
		</h:form>

		<h:form id="lista">
			<h:dataTable value="#{construtoraBean.lista}" var="construtora"
				border="1" rendered="#{not empty construtoraBean.lista}">
				<f:facet name="header">Listagem de Construtoras</f:facet>
				<h:column>
					<f:facet name="header">Razão Social</f:facet>
					#{construtora.razaoSocial}
				</h:column>

				<h:column>
					<f:facet name="header">CNPJ</f:facet>
					#{construtora.cnpj}
				</h:column>

				<h:column>
					<f:facet name="header">Data Cadastro</f:facet>
					<h:outputText value="#{construtora.dataCadastro}">
						<f:convertDateTime dateStyle="medium" />
					</h:outputText>

				</h:column>
				<h:column>
					<f:facet name="header">Ações:</f:facet>
					<h:commandLink action="#{construtoraBean.excluir}"
						onclick="if(!confirm('Deseja realmente escluir a construtora #{construtora.razaoSocial}?')) return false;">
						<h:graphicImage library="imagens" name="remove-icon.png" />
						<f:setPropertyActionListener
							target="#{construtoraBean.construtoraSelecionada}"
							value="#{construtora}" />
					</h:commandLink>
					<h:outputText value="---" />
					<h:commandLink>
						<h:graphicImage library="imagens" name="edit-icon.png" />
						<f:setPropertyActionListener
							target="#{construtoraBean.construtoraSelecionada}"
							value="#{construtora}" />
					</h:commandLink>
				</h:column>
			</h:dataTable>

		</h:form>
	</ui:define>
</ui:composition>

</html>